import pickle

# 序列化Python对象
# 需要将一个Python对象序列化为一个字节流，落地到文件
def demo_1():
    data = {'kepler test', 'hello', 'world'}
    f = open('../temp/pickle_test.txt', 'wb')
    # 序列化对象到文件
    pickle.dump(data, f)


# 反序列化文件为对象
def demo_2():
    f1 = open('../temp/pickle_test.txt', 'rb')
    data_temp = pickle.load(f1)
    print(data_temp)

if __name__ == '__main__':
    # demo_1()
    demo_2()